package collection;

import java.util.LinkedList;

public class LinkedDemo1 {
    public static void main(String[] args) {
        LinkedList<Integer> link = new LinkedList<>();
        link.add(100);
        link.add(200);
        link.add(300);
        System.out.println(link);
        link.addFirst(50);
        link.addLast(700);
        System.out.println(link);

        //获取头、尾部元素
        int first = link.getFirst();
        int last = link.getLast();
        System.out.println(first);
        System.out.println(last);

        //删除头部元素
        link.removeFirst();
        System.out.println(link);
        link.remove(2);
        System.out.println(link);
    }
}
